/*
 * @Author: mayijun
 * @Date: 2022-06-30 09:48:42
 * @LastEditors: mayijun
 * @LastEditTime: 2022-06-30 14:50:11
 */
import { defineComponent, computed, unref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import APageCaontainer from '@dangojs/a-page-container';
import useAppStore from '@/store/app';


export default defineComponent({
  name: 'PageContainer',
  inheritAttrs: false,
  setup(props, {attrs, slots }) {
    // const colCapse = () => {
    //   console.log('colCapse')
    // }
    const route = useRoute();
    const router = useRouter();
    const appStore = useAppStore();
    const collapse = (val: boolean) => {
      console.log(val);
      appStore.updateSettings({ menuCollapse: val });
    };
    const onBack = () => {
      router.go(-1);
    }
    const attrAndProps = computed(() => ({ title: route.meta.title, onCollapse: collapse, onBack, ...unref(attrs), ...props}));
    // if(slots.title){

    // }
    return () => {
      // @ts-ignore
      return <APageCaontainer {...attrAndProps.value} v-slots={slots}></APageCaontainer>;
    };
  }
});
